﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace TdxConnector
{
    //确保tdxapi.dll位于券商下单软件安装目录中。
    //本解决方案生成的TdxApiPlugin.dll输出到券商下单软件安装目录下的plugin文件夹中
    //本解决方案生成的TdxApiDemo.dll输出到券商下单软件安装目录中
    static class NativeAPI
    {
        const string API_DLL = "tdxapi.dll";

        [DllImport(API_DLL, CharSet = CharSet.Ansi)]
        [return: MarshalAs(UnmanagedType.I1)]
        public static extern bool Tdx_Login(string Password, StringBuilder Msg);

        [DllImport(API_DLL, CharSet = CharSet.Ansi)]
        public static extern void Tdx_Logout();

        [DllImport(API_DLL, CharSet = CharSet.Ansi)]
        public static extern void Tdx_GetWndText(StringBuilder Data);

        [DllImport(API_DLL, CharSet = CharSet.Ansi)]
        public static extern void Tdx_GetAccount(StringBuilder Data);

        [DllImport(API_DLL, CharSet = CharSet.Ansi)]
        public static extern void Tdx_QueryData(int Category, StringBuilder Data, StringBuilder Msg);

        [DllImport(API_DLL, CharSet = CharSet.Ansi)]
        public static extern int Tdx_SendOrder(int Category, string Zqdm, double Price, int Quantity, StringBuilder Msg);

        [DllImport(API_DLL, CharSet = CharSet.Ansi)]
        [return: MarshalAs(UnmanagedType.I1)]
        public static extern bool Tdx_CancelOrder(int hth, StringBuilder Msg);
    }
}
